<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateTableAdminUser extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('admin_user', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('admin_role_id', false, true)->default(0)->comment('关联角色');
            $table->string('image_path', 255)->default('')->comment('头像图片路径');
            $table->string('name', 255)->nullable(false)->comment('登录名');
            $table->tinyInteger('sex', false, true)->default(0)->comment('性别，0未知，1男，2女');
            $table->char('password_salt', 8)->nullable(false)->comment('密码加盐');
            $table->char('password', 40)->nullable(false)->comment('SHA1(密码+盐)');
            $table->string('email', 100)->default('')->comment('邮件地址');
            $table->string('phone', 50)->default('')->comment('手机或电话');
            $table->string('address', 255)->default('')->comment('住址');
            $table->text('about_me')->nullable()->comment('自我介绍');
            $table->timestamp('last_login')->nullable()->comment('最近登录时间');
            $table->string('last_ip', 64)->default('')->comment('最近登录的IP');
            $table->timestamps();
            $table->softDeletes();
            $table->unique('name', 'name');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('admin_user');
    }
}
